package pr2;

import java.awt.GridBagLayout;
import java.awt.GridLayout;
import java.awt.event.ActionListener;
import java.awt.event.KeyListener;

import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

public class menu_alta extends JFrame {
	
	private JPanel pan,pan2,pan3,pan4;
	private JTextField in_code, in_price;
	private JLabel code,price,state,tipo;
	private JComboBox jc_state, jc_tipo;
	private String[] estados = { "Disponible", "En reparación" , "Alquilado"};
	private String[] tipos = { "Tabla de surf", "Patinete" , "Paddle"};
	private JButton aceptar,cancelar;
	
	public menu_alta(){
		super("Que has comprado nuevo, querido Rudolf?");
		setLayout(new GridLayout(4,1,5,5));
		
		setSize(600,200);
		
		
		pan = new JPanel();
		pan2 = new JPanel();
		pan3 = new JPanel();
		pan4 = new JPanel();
		
		pan.setBorder(BorderFactory.createEmptyBorder(0, 10, 10, 10));
		pan2.setBorder(BorderFactory.createEmptyBorder(0, 20, 20, 20));
		pan3.setBorder(BorderFactory.createEmptyBorder(0, 10, 10, 10));
		
		code = new JLabel("Introduzca codigo de referencia: ");
		in_code = new JTextField("0000");
		in_code.setActionCommand("code");

		pan.add(code);
		pan.add(in_code);
		
		add(pan);
		
		price = new JLabel("Introduzca precio por hora de alquiler (en Euros): ");
		in_price = new JTextField("0000");
		in_price.setActionCommand("price");
		
		pan2.add(price);
		pan2.add(in_price);
		
		add(pan2);
		
		jc_tipo = new JComboBox(tipos);
		jc_state = new JComboBox(estados);
		
		pan3.add(jc_tipo);
		pan3.add(jc_state);
		
		add(pan3);
		
		aceptar = new JButton("Aceptar");
		aceptar.setActionCommand("aceptar");
		cancelar = new JButton("Cancelar");
		cancelar.setActionCommand("cancelar");
		pan4.add(aceptar);
		pan4.add(cancelar);
		
		add(pan4);
		
		setVisible(true);

		
	}
	
	public void setActionListener (ActionListener l){
		
		aceptar.addActionListener(l);
		cancelar.addActionListener(l);
		in_code.addActionListener(l);
		in_price.addActionListener(l);

	}
	public void blankcode(){
		in_code.setText("");
	}
	public void blankprice(){
		in_price.setText("");
	}


	public JTextField getIn_code() {
		return in_code;
	}

	public void setIn_code(JTextField in_code) {
		this.in_code = in_code;
	}

	public JTextField getIn_price() {
		return in_price;
	}

	public void setIn_price(JTextField in_price) {
		this.in_price = in_price;
	}

	public JComboBox getJc_state() {
		return jc_state;
	}

	public void setJc_state(JComboBox jc_state) {
		this.jc_state = jc_state;
	}

	public JComboBox getJc_tipo() {
		return jc_tipo;
	}

	public void setJc_tipo(JComboBox jc_tipo) {
		this.jc_tipo = jc_tipo;
	}

}
